/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaEmpresa.java
 *
 * Created on 31/10/2010, 19:26:52
 */
package asfabdesk.apresentacao;

import asfabdesk.dominio.Data;
import asfabdesk.dominio.EmpresaConveniada;
import asfabdesk.dominio.TipoServico;
import asfabdesk.presistencia.DAO;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;

/**
 *
 * @author Mathias
 */
public class TelaEmpresa extends javax.swing.JInternalFrame {

    private EmpresaConveniada empresa = new EmpresaConveniada();

    /** Creates new form TelaEmpresa */
    public TelaEmpresa() throws SQLException {
        initComponents();
        configurarComboTipoServico();
    }

     public void salvarEmpresa() {
        if (verificarCampos()) {
            if (verificarUniques()) {
                empresa = povoarEmpresa();
                try {
                    new DAO().salvar(empresa);
                    JOptionPane.showMessageDialog(null, "Empresa Cadastrada com Sucesso'.", "Sucesso", 1);
//                    configurarParaCadastroSalvo();
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Ops, ocorreu um erro durante o cadastro'.", "Ops,erro!", 0);
                    e.printStackTrace();
                }
            }
        }
    }

     public void configurarParaCadastroNovo(){
         limparCampos();
     }


    public void configurarComboTipoServico() throws SQLException {
        comboTipoServiço.removeAllItems();
        comboTipoServiço.addItem("");
        comboTipoServiço.setSelectedItem("");
        java.util.List servicos = (new DAO()).listar(TipoServico.class);
        for (int i = 0; i < servicos.size(); i++) {
            String descricao = ((TipoServico) servicos.get(i)).getDescricao();
            comboTipoServiço.addItem(descricao);
        }
    }

    public EmpresaConveniada povoarEmpresa() {
        EmpresaConveniada empre = new EmpresaConveniada();
        empre.setNomeFantasia(txtNomeFantasia.getText().toUpperCase());
        empre.setRazaoSocial(txtRazaoSocial.getText().toUpperCase());
        empre.setCnpj(txtCnpj.getText());
        empre.setLogradouro(txtLogradouro.getText());
        empre.setNumero(txtNumero.getText());
        empre.setComplemento(txtComplemento.getText());
        empre.setCidade(txtCidade.getText());
        empre.setUf(comboUf.getSelectedItem().toString());
        empre.setCep(txtCep.getText());
        empre.setNomeContato(txtNomeContato.getText());
        empre.setTelContato(txtTelContato.getText());
        empre.setTel1(txtTel1.getText());
        empre.setTel2(txtTel2.getText());
        empre.setEmail(txtEmail.getText());
        empre.setHomePag(txtSite.getText());
        TipoServico servico = (new DAO().localizar(TipoServico.class, "TipoServicoPorNome",comboTipoServiço.getSelectedItem().toString()));
        empre.setTipoServico(servico);
        Date data = new Date();
        String dataString = (String) new Data().ConverteDataHoraDateStringBra(data);
        try {
            data = new Data().ConverteDataHoraStringDate(dataString);
        } catch (ParseException ex) {
            Logger.getLogger(TelaConvenio.class.getName()).log(Level.SEVERE, null, ex);
        }
        empre.setDataCadastro(data);
        empre.setUsuarioCadastrante(TelaLogin.usuario);
        
        return empre;

    }

    public boolean verificarCampos() {
        boolean retorno = true;
        StringBuffer campos = new StringBuffer();
        String str = "";

        if (comboTipoServiço.getSelectedItem().toString().equals("")) {
            str = " (Tipo Serviço) ";
            campos.append(str);
            retorno = false;
        }

        if (txtNomeFantasia.getText().equals("")) {
            str = "(Nome Fantasia) ";
            campos.append(str);
            retorno = false;
        }

        if (txtRazaoSocial.getText().equals("")) {
            str = "(Razão Social) ";
            campos.append(str);
            retorno = false;
        }

        if (txtCnpj.getText().equals("  .   .   /    -  ")) {
            str = "(CNPJ) ";
            campos.append(str);
            retorno = false;
        }

        if (retorno == false) {
            JOptionPane.showMessageDialog(null, "Ops, você não preencheu o(s) seguinte(s) campo(s) obrigatório(s): " + '\n' + campos, "Campos Obrigatórios.", 2);
        }
        return retorno;
    }

    public boolean verificarUniques() {
        StringBuffer campos = new StringBuffer();
        String string = "";
        boolean retorno = true;

        if (new DAO().localizar(EmpresaConveniada.class, "EmpresaPorNomeFantasia", txtNomeFantasia.getText()) != null) {
            string = " (Nome Fantasia= " + txtNomeFantasia.getText() + ") ";
            campos.append(string);
            retorno = false;
        }

        if (new DAO().localizar(EmpresaConveniada.class, "EmpresaPorRazaoSocial", txtRazaoSocial.getText()) != null) {
            string = " (Razão Social= " + txtRazaoSocial.getText() + ") ";
            campos.append(string);
            retorno = false;
        }

        if (new DAO().localizar(EmpresaConveniada.class, "EmpresaPorCnpj", txtCnpj.getText()) != null) {
            string = " (CNPJ= " + txtCnpj.getText() + ") ";
            campos.append(string);
            retorno = false;
        }

        if (retorno == false) {
            JOptionPane.showMessageDialog(null, "Ops, você está tentando salvar campo(s) já cadastrado(s): " + '\n' + campos, "Campos Únicos.", 2);
        }
        return retorno;
    }

    public void limparCampos(){
        comboTipoServiço.setSelectedIndex(0);
        txtNomeFantasia.setText("");
        txtRazaoSocial.setText("");
        txtCnpj.setText("");
        txtLogradouro.setText("");
        txtNumero.setText("");
        txtComplemento.setText("");
        txtCidade.setText("");
        comboUf.setSelectedIndex(0);
        txtCep.setText("");
        txtNomeContato.setText("");
        txtTelContato.setText("");
        txtTel1.setText("");
        txtTel2.setText("");
        txtEmail.setText("");
        txtSite.setText("");
    }
    
    public void abrirIFrame(JInternalFrame janela) {
        for (JInternalFrame j : TelaPrincipal.desktop.getAllFrames()) {
            if (janela.getClass() == j.getClass()) {
                j.moveToFront();
                return;
            }
        }
        TelaPrincipal.desktop.add(janela);
        janela.setVisible(true);
    }

     private void chamarTipoServico() {
        TelaTipoDeServico ts = new TelaTipoDeServico();
        FrameListenerEmpresa fl = new FrameListenerEmpresa();
        ts.addInternalFrameListener(fl);
        abrirIFrame(ts);
    }

    private class FrameListenerEmpresa implements InternalFrameListener {

        public void internalFrameClosed(InternalFrameEvent e) {
            try {
                configurarComboTipoServico();
            } catch (SQLException ex) {
                Logger.getLogger(TelaEmpresa.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        public void internalFrameOpened(InternalFrameEvent e) {
//            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void internalFrameClosing(InternalFrameEvent e) {
//            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void internalFrameIconified(InternalFrameEvent e) {
//            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void internalFrameDeiconified(InternalFrameEvent e) {
//            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void internalFrameActivated(InternalFrameEvent e) {
//            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void internalFrameDeactivated(InternalFrameEvent e) {
//            throw new UnsupportedOperationException("Not supported yet.");
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        txtLogradouro = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtNumero = new javax.swing.JTextField();
        txtComplemento = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txtCidade = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        comboUf = new javax.swing.JComboBox();
        txtCep = new javax.swing.JFormattedTextField();
        jLabel25 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        txtNomeContato = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtTelContato = new javax.swing.JFormattedTextField();
        txtTel1 = new javax.swing.JFormattedTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        txtTel2 = new javax.swing.JFormattedTextField();
        txtSite = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        painel1 = new javax.swing.JPanel();
        txtNomeFantasia = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        txtRazaoSocial = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtCnpj = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        comboTipoServiço = new javax.swing.JComboBox();
        btnNovoTipoServico = new javax.swing.JButton();
        bfInferior = new javax.swing.JToolBar();
        btnSalvar = new javax.swing.JButton();
        btnEditar = new javax.swing.JButton();
        btnAtivaInativa = new javax.swing.JButton();
        btnImprimir = new javax.swing.JButton();
        btnNovo = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(asfabdesk.apresentacao.AsfabDeskApp.class).getContext().getResourceMap(TelaEmpresa.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel12.setIcon(resourceMap.getIcon("jLabel12.icon")); // NOI18N
        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLabel12.setName("jLabel12"); // NOI18N
        jPanel2.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 0, -1, -1));

        jTabbedPane1.setBackground(resourceMap.getColor("jTabbedPane1.background")); // NOI18N
        jTabbedPane1.setForeground(resourceMap.getColor("jTabbedPane1.foreground")); // NOI18N
        jTabbedPane1.setFont(resourceMap.getFont("jTabbedPane1.font")); // NOI18N
        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel4.setBackground(resourceMap.getColor("jPanel4.background")); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel5.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel5.setForeground(resourceMap.getColor("jLabel5.foreground")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jPanel4.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 33, -1, -1));

        txtLogradouro.setText(resourceMap.getString("txtLogradouro.text")); // NOI18N
        txtLogradouro.setName("txtLogradouro"); // NOI18N
        jPanel4.add(txtLogradouro, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 52, 274, -1));

        jLabel6.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel6.setForeground(resourceMap.getColor("jLabel6.foreground")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N
        jPanel4.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 80, -1, -1));

        jLabel7.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel7.setForeground(resourceMap.getColor("jLabel7.foreground")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        jPanel4.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 80, -1, -1));

        txtNumero.setText(resourceMap.getString("txtNumero.text")); // NOI18N
        txtNumero.setName("txtNumero"); // NOI18N
        jPanel4.add(txtNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 97, 70, -1));

        txtComplemento.setText(resourceMap.getString("txtComplemento.text")); // NOI18N
        txtComplemento.setName("txtComplemento"); // NOI18N
        jPanel4.add(txtComplemento, new org.netbeans.lib.awtextra.AbsoluteConstraints(94, 97, 200, -1));

        jLabel8.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel8.setForeground(resourceMap.getColor("jLabel8.foreground")); // NOI18N
        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N
        jPanel4.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, -1, -1));

        txtCidade.setText(resourceMap.getString("txtCidade.text")); // NOI18N
        txtCidade.setName("txtCidade"); // NOI18N
        jPanel4.add(txtCidade, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 142, 220, -1));

        jLabel9.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel9.setForeground(resourceMap.getColor("jLabel9.foreground")); // NOI18N
        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N
        jPanel4.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 120, -1, 20));

        jLabel14.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel14.setForeground(resourceMap.getColor("jLabel14.foreground")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N
        jPanel4.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 168, -1, -1));

        jLabel2.setIcon(resourceMap.getIcon("jLabel2.icon")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel4.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 0, 20, -1));

        jLabel10.setFont(resourceMap.getFont("jLabel10.font")); // NOI18N
        jLabel10.setForeground(resourceMap.getColor("jLabel10.foreground")); // NOI18N
        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N
        jPanel4.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1));

        jLabel11.setIcon(resourceMap.getIcon("jLabel11.icon")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N
        jPanel4.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 220, -1, -1));

        comboUf.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "RJ" }));
        comboUf.setName("comboUf"); // NOI18N
        jPanel4.add(comboUf, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 140, 40, -1));

        try {
            txtCep.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtCep.setName("txtCep"); // NOI18N
        jPanel4.add(txtCep, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 190, 60, -1));

        jLabel25.setFont(resourceMap.getFont("jLabel25.font")); // NOI18N
        jLabel25.setForeground(resourceMap.getColor("jLabel25.foreground")); // NOI18N
        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N
        jPanel4.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 123, -1, -1));

        jPanel3.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 310, 240));

        jPanel7.setBackground(resourceMap.getColor("jPanel7.background")); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N
        jPanel7.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        txtNomeContato.setText(resourceMap.getString("txtNomeContato.text")); // NOI18N
        txtNomeContato.setName("txtNomeContato"); // NOI18N
        jPanel7.add(txtNomeContato, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 52, 155, -1));

        jLabel15.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel15.setForeground(resourceMap.getColor("jLabel15.foreground")); // NOI18N
        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N
        jPanel7.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 33, -1, -1));

        jLabel16.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel16.setForeground(resourceMap.getColor("jLabel16.foreground")); // NOI18N
        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jPanel7.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(179, 33, -1, -1));

        try {
            txtTelContato.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtTelContato.setName("txtTelContato"); // NOI18N
        jPanel7.add(txtTelContato, new org.netbeans.lib.awtextra.AbsoluteConstraints(179, 52, 83, -1));

        try {
            txtTel1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtTel1.setName("txtTel1"); // NOI18N
        jPanel7.add(txtTel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 97, 83, -1));

        jLabel17.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel17.setForeground(resourceMap.getColor("jLabel17.foreground")); // NOI18N
        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N
        jPanel7.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 78, -1, -1));

        jLabel18.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel18.setForeground(resourceMap.getColor("jLabel18.foreground")); // NOI18N
        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N
        jPanel7.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(107, 78, -1, -1));

        try {
            txtTel2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtTel2.setName("txtTel2"); // NOI18N
        jPanel7.add(txtTel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(107, 97, 83, -1));

        txtSite.setText(resourceMap.getString("txtSite.text")); // NOI18N
        txtSite.setName("txtSite"); // NOI18N
        jPanel7.add(txtSite, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 187, 260, -1));

        jLabel20.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel20.setForeground(resourceMap.getColor("jLabel20.foreground")); // NOI18N
        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N
        jPanel7.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 168, -1, -1));

        txtEmail.setText(resourceMap.getString("txtEmail.text")); // NOI18N
        txtEmail.setName("txtEmail"); // NOI18N
        jPanel7.add(txtEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 142, 260, -1));

        jLabel19.setFont(resourceMap.getFont("jLabel18.font")); // NOI18N
        jLabel19.setForeground(resourceMap.getColor("jLabel19.foreground")); // NOI18N
        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N
        jPanel7.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 123, -1, -1));

        jLabel13.setIcon(resourceMap.getIcon("jLabel13.icon")); // NOI18N
        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N
        jPanel7.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 0, -1, -1));

        jLabel21.setIcon(resourceMap.getIcon("jLabel21.icon")); // NOI18N
        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N
        jPanel7.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 220, -1, -1));

        jLabel22.setFont(resourceMap.getFont("jLabel10.font")); // NOI18N
        jLabel22.setForeground(resourceMap.getColor("jLabel22.foreground")); // NOI18N
        jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
        jLabel22.setName("jLabel22"); // NOI18N
        jPanel7.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1));

        jPanel3.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 120, 300, 240));

        painel1.setBackground(resourceMap.getColor("painel1.background")); // NOI18N
        painel1.setName("painel1"); // NOI18N
        painel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        txtNomeFantasia.setText(resourceMap.getString("txtNomeFantasia.text")); // NOI18N
        txtNomeFantasia.setName("txtNomeFantasia"); // NOI18N
        painel1.add(txtNomeFantasia, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 200, -1));

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        painel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, -1));

        txtRazaoSocial.setText(resourceMap.getString("txtRazaoSocial.text")); // NOI18N
        txtRazaoSocial.setName("txtRazaoSocial"); // NOI18N
        painel1.add(txtRazaoSocial, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 80, 200, -1));

        jLabel3.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel3.setForeground(resourceMap.getColor("jLabel3.foreground")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N
        painel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 60, -1, -1));

        try {
            txtCnpj.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###/####-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtCnpj.setName("txtCnpj"); // NOI18N
        painel1.add(txtCnpj, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 80, 115, -1));

        jLabel4.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel4.setForeground(resourceMap.getColor("jLabel4.foreground")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N
        painel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 60, -1, -1));

        jLabel23.setFont(resourceMap.getFont("jLabel23.font")); // NOI18N
        jLabel23.setForeground(resourceMap.getColor("jLabel23.foreground")); // NOI18N
        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N
        painel1.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, 10));

        comboTipoServiço.setName("comboTipoServiço"); // NOI18N
        painel1.add(comboTipoServiço, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 130, -1));

        btnNovoTipoServico.setText(resourceMap.getString("btnNovoTipoServico.text")); // NOI18N
        btnNovoTipoServico.setName("btnNovoTipoServico"); // NOI18N
        btnNovoTipoServico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoTipoServicoActionPerformed(evt);
            }
        });
        painel1.add(btnNovoTipoServico, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 30, -1, -1));

        jPanel3.add(painel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 640, 120));

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        jPanel2.add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, 400));

        bfInferior.setFloatable(false);
        bfInferior.setName("bfInferior"); // NOI18N
        bfInferior.setOpaque(false);

        btnSalvar.setForeground(resourceMap.getColor("btnSalvar.foreground")); // NOI18N
        btnSalvar.setIcon(resourceMap.getIcon("btnSalvar.icon")); // NOI18N
        btnSalvar.setText(resourceMap.getString("btnSalvar.text")); // NOI18N
        btnSalvar.setFocusable(false);
        btnSalvar.setName("btnSalvar"); // NOI18N
        btnSalvar.setOpaque(false);
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });
        bfInferior.add(btnSalvar);

        btnEditar.setForeground(resourceMap.getColor("btnEditar.foreground")); // NOI18N
        btnEditar.setIcon(resourceMap.getIcon("btnEditar.icon")); // NOI18N
        btnEditar.setText(resourceMap.getString("btnEditar.text")); // NOI18N
        btnEditar.setFocusable(false);
        btnEditar.setName("btnEditar"); // NOI18N
        btnEditar.setOpaque(false);
        bfInferior.add(btnEditar);

        btnAtivaInativa.setForeground(resourceMap.getColor("btnAtivaInativa.foreground")); // NOI18N
        btnAtivaInativa.setIcon(resourceMap.getIcon("btnAtivaInativa.icon")); // NOI18N
        btnAtivaInativa.setText(resourceMap.getString("btnAtivaInativa.text")); // NOI18N
        btnAtivaInativa.setName("btnAtivaInativa"); // NOI18N
        btnAtivaInativa.setOpaque(false);
        bfInferior.add(btnAtivaInativa);

        btnImprimir.setForeground(resourceMap.getColor("btnImprimir.foreground")); // NOI18N
        btnImprimir.setIcon(resourceMap.getIcon("btnImprimir.icon")); // NOI18N
        btnImprimir.setText(resourceMap.getString("btnImprimir.text")); // NOI18N
        btnImprimir.setFocusable(false);
        btnImprimir.setMaximumSize(new java.awt.Dimension(80, 33));
        btnImprimir.setMinimumSize(new java.awt.Dimension(80, 33));
        btnImprimir.setName("btnImprimir"); // NOI18N
        btnImprimir.setOpaque(false);
        btnImprimir.setPreferredSize(new java.awt.Dimension(67, 33));
        bfInferior.add(btnImprimir);

        btnNovo.setForeground(resourceMap.getColor("btnNovo.foreground")); // NOI18N
        btnNovo.setIcon(resourceMap.getIcon("btnNovo.icon")); // NOI18N
        btnNovo.setText(resourceMap.getString("btnNovo.text")); // NOI18N
        btnNovo.setFocusable(false);
        btnNovo.setName("btnNovo"); // NOI18N
        btnNovo.setOpaque(false);
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });
        bfInferior.add(btnNovo);

        jPanel2.add(bfInferior, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 420, 650, -1));

        jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 670, 470));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 690, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 490, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        configurarParaCadastroNovo();
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
        salvarEmpresa();
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnNovoTipoServicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoTipoServicoActionPerformed
        chamarTipoServico();
    }//GEN-LAST:event_btnNovoTipoServicoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar bfInferior;
    private javax.swing.JButton btnAtivaInativa;
    private javax.swing.JButton btnEditar;
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnNovoTipoServico;
    private javax.swing.JButton btnSalvar;
    private javax.swing.JComboBox comboTipoServiço;
    private javax.swing.JComboBox comboUf;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel painel1;
    private javax.swing.JFormattedTextField txtCep;
    private javax.swing.JTextField txtCidade;
    private javax.swing.JFormattedTextField txtCnpj;
    private javax.swing.JTextField txtComplemento;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtLogradouro;
    private javax.swing.JTextField txtNomeContato;
    private javax.swing.JTextField txtNomeFantasia;
    private javax.swing.JTextField txtNumero;
    private javax.swing.JTextField txtRazaoSocial;
    private javax.swing.JTextField txtSite;
    private javax.swing.JFormattedTextField txtTel1;
    private javax.swing.JFormattedTextField txtTel2;
    private javax.swing.JFormattedTextField txtTelContato;
    // End of variables declaration//GEN-END:variables
}
